﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI.WebControls;
using System.Collections;

namespace Catering.View_Operaction
{
    public class Caipin_Manage_Operaction
    {
        #region 选择原料添加到菜品
        public string GetTableHtml(string intId)
        {
            System.Text.StringBuilder sb_Dish = new System.Text.StringBuilder();
            Catering_Rules.T_DishInfo crdi = new Catering_Rules.T_DishInfo();
            DataSet ds = crdi.GetList("DID=" + intId);
            if (ds != null && ds.Tables.Count > 0)
            {
                DataTable dt = ds.Tables[0];
                int i = 1;
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr != null)
                    {
                        sb_Dish.Append("<tr>  ");
                        sb_Dish.Append("    <td class='xh_td'>" + i + " </td>");
                        sb_Dish.Append("    <td id='RawName'>" + dr["DName"] + "</td>");
                        sb_Dish.Append("    <td>" + dr["zs"] + "</td>");
                        sb_Dish.Append("    <td id='leibie'>" + dr["Content"] + " </td>");
                        sb_Dish.Append("     <td>" + dr["Re"] + "</td>");
                        sb_Dish.Append("     <td align='center'><a href='#' ></td>");
                        sb_Dish.Append("    </tr>");
                        i++;
                    }
                }
            }
            return sb_Dish.ToString();
        }
        public string GetTableHtml(Int32 intId, string strName, string strTypeName, string strRe)
        {
            System.Text.StringBuilder sb_Dish = new System.Text.StringBuilder();
            sb_Dish.Append("<tr>  ");
            sb_Dish.Append("    <td class='xh_td'>" + intId + " </td>");
            sb_Dish.Append("    <td id='RawName'>" + strName + "</td>");
            sb_Dish.Append("    <td>" + strTypeName + "</td>");
            sb_Dish.Append("    <td id='leibie'> <input type='text'  value='100' ID='Txt_jinghanliang" + intId + "' style='width:50px' onpropertychange='Txt_Number_Chanage(" + intId + ")'/></td>");
            sb_Dish.Append("     <td>" + strRe + "</td>");
            sb_Dish.Append("     <td align='center'><a href='#' onclick='Del_DishInfo(" + intId + ")'>");
            sb_Dish.Append("   <img src='../../../Images/trash.gif' /></a></td>");
            sb_Dish.Append("    </tr>");
            return sb_Dish.ToString();
        }
        #endregion

        public DataTable setDataToDataTable(DataTable dt, Int32 intId, string strName, string strTypeName, string strRe, string strRawID,string strzl="")
        {
            DataRow dr = dt.NewRow();
            dr["Id"] = intId;//虚拟主键
            dr["Food"] = strName;//原料名称
            dr["zs"] = strTypeName;//原料细类
            dr["zl"] =((strzl=="")?"100":strzl);    //默认净用量
            if (strRe.Length > 0)//热量
            {
                dr["Re"] = Convert.ToDouble(strRe);// * 100
            }
            else
            {
                dr["Re"] = 0;
            }
            dr["RawID"] = strRawID;
            dt.Rows.Add(dr);
            return dt;

        }

        //原料元素信息
        public DataTable Nutrient_DataSetToDatatabl()
        {
            DataTable dt = new Catering_DataSet.RAW_ElementsDataTable();
            Catering_Rules.ViewOperaction crvo = new Catering_Rules.ViewOperaction();
            Catering_Rules.T_RawMaterial crrm = new Catering_Rules.T_RawMaterial();
            DataSet ds_Raw = crrm.GetAllList();
            if (ds_Raw != null && ds_Raw.Tables.Count > 0)
            {
                DataTable dt_Raw = ds_Raw.Tables[0];
                for (int j = 1; j <= dt_Raw.Rows.Count; j++)
                {
                    DataRow dr = dt.NewRow();
                    DataSet ds_Nutrient = crvo.GetViewToDataSet("Nutrient");
                    if (ds_Nutrient != null && ds_Nutrient.Tables.Count > 0)
                    {
                        for (int i = 1; i <= 24; i++)
                        {
                            DataRow[] dr_Nutrient = ds_Nutrient.Tables[0].Select("NutritionElementsID=" + i + " and RawID=" + dt_Raw.Rows[j-1]["id"]);
                            if (dr_Nutrient.Length > 0)
                            {
                                dr[i] = dr_Nutrient[0]["Content"].ToString();

                            }
                        }
                        dr[0] = dt_Raw.Rows[j - 1]["id"].ToString();
                        dr[25] = dt_Raw.Rows[j - 1]["RAWName"].ToString();
                        if (dr[1] != null && dr[1].ToString().Length > 0)
                        {
                            dt.Rows.Add(dr);
                        }
                    }
                }
            }
            return dt;
        }
        //菜品元素
        public DataTable Dish_DataSetToDatatabl(string strDishid)
        {
            DataTable dt = new Catering_DataSet.Dish_ElementsDataTable();

            Catering_Rules.DishNutrien crrm = new Catering_Rules.DishNutrien();
            DataSet ds_Raw = crrm.GetList("Dishid=" + strDishid);
            if (ds_Raw != null && ds_Raw.Tables.Count > 0)
            {
                DataTable dt_Raw = ds_Raw.Tables[0];
                DataRow dr = dt.NewRow();
                for (int j = 2; j < dt_Raw.Rows.Count; j++)
                {
                    if (j != 7 && j != 17)
                    {
                        dr[j] = dt_Raw.Rows[j]["Content"].ToString();
                    }

                }
                dr[0] = strDishid;
                dt.Rows.Add(dr);
            }
            return dt;
        }
        #region 树形结构节点删除
        public Boolean Del_Dish_Info(string strDishId)
        {
            Boolean bl = false;
            string strDish = strDishId.Substring(strDishId.LastIndexOf("\\") + 1);


            Catering_Rules.DishNutrien crdn = new Catering_Rules.DishNutrien();
            List<Catering_Model.DishNutrien> listNutrien = crdn.GetModelList("Dishid=" + strDish);
            string strNutrien = string.Empty;
            foreach (Catering_Model.DishNutrien cmdn in listNutrien)
            {
                strNutrien = strNutrien + cmdn.id + ",";
            }
            if (strNutrien.Length > 1)
            {
                bl = crdn.DeleteList(strNutrien.Substring(0, strNutrien.Length - 1));
            }
            else
            {
                bl = true;
            }
            if (bl)
            {
                Catering_Rules.T_DishInfo crdi = new Catering_Rules.T_DishInfo();
                List<Catering_Model.E_DishInfo> listInfo = crdi.GetModelList("DTD=" + strDishId);
                string strInfo = string.Empty;
                foreach (Catering_Model.E_DishInfo cmdi in listInfo)
                {
                    strInfo = strInfo + ",";

                }
                if (strInfo.Length > 1)
                {
                    bl = crdi.DeleteList(strInfo.Substring(0, strInfo.Length - 1));
                }
                else
                {
                    bl = true;
                }
                if (bl)
                {
                    Catering_Rules.T_Dish crd = new Catering_Rules.T_Dish();
                    bl = crd.Delete(Convert.ToInt32(strDish));
                }
            }

            return bl;
        }
        public Boolean Del_Raw_Info(string strRawId)
        {
            strRawId = strRawId.Substring(strRawId.LastIndexOf("\\") + 1);
            Boolean bl = false;
            Catering_Rules.NutrientComposition crnc = new Catering_Rules.NutrientComposition();
            List<Catering_Model.NutrientComposition> listnc = crnc.GetModelList("RawID=" + strRawId);
            string strNc = string.Empty;
            foreach (Catering_Model.NutrientComposition cmnc in listnc)
            {
                strNc = strNc + cmnc.id + ",";
            }
            if (strNc.Length > 1)
            {

                bl = crnc.DeleteList(strNc.Substring(0, strNc.Length - 1));
            }
            else
            {
                bl = true;
            }
            if (bl)
            {
                Catering_Rules.RAEInfo crri = new Catering_Rules.RAEInfo();
                List<Catering_Model.RAEInfo> listInfo = crri.GetModelList("RAWID=" + strRawId);
                string strInfo = string.Empty;
                foreach (Catering_Model.RAEInfo cmri in listInfo)
                {
                    strInfo = strInfo + cmri.id + ",";

                }
                if (strInfo.Length > 1)
                {
                    bl = crri.DeleteList(strInfo.Substring(0, strInfo.Length - 1));
                }
                else
                {
                    bl = true;
                }
                if (bl)
                {
                    Catering_Rules.T_RawMaterial crrm = new Catering_Rules.T_RawMaterial();
                    bl = crrm.Delete(Convert.ToInt32(strRawId));
                }
            }
            return bl;
        }

        public Boolean Del_Dish_Type(string strDishId)
        {
            Boolean bl = false;
            Catering_Rules.DishType crdt = new Catering_Rules.DishType();
            bl = crdt.Delete(Convert.ToInt32(strDishId));
            return bl;
        }


        public Boolean Del_Raw_Type(string strDishId)
        {
            Boolean bl = false;
            Catering_Rules.T_RawMaterials crdt = new Catering_Rules.T_RawMaterials();
            Catering_Rules.RawMaterialsInfo crri = new Catering_Rules.RawMaterialsInfo();
            try
            {
                crri.DeleteList("  RMID=" + strDishId);
                bl = crdt.Delete(Convert.ToInt32(strDishId));

            }
            catch
            {
                bl = true;
            }
            return bl;
        }

        /// <summary>
        /// 删除一条原料细类
        /// </summary>
        public Boolean DelRawMaterialsInfoByID(int strid)
        {
            return new Catering_Rules.RawMaterialsInfo().Delete(strid);
        }



        public Boolean Del_DishInfo_Operaction(string strDishId)
        {
            Boolean bl = false;
            //DataTable dt = Catering.Catering_Page.Caipin.Ccaipin_jcsz.Caipinshezhi.dt_yuanliao;
            //dt.Rows[Convert.ToInt32(strDishId) - 1].Delete();
            return bl;
        }
        #endregion

        #region 基础设置-类别设置
        #region 类别设置-原料设置
        public string GetRawType()
        {
            string strRawHtml = string.Empty;
            Catering_Rules.T_RawMaterials crrm = new Catering_Rules.T_RawMaterials();
            DataSet ds = crrm.GetAllList();
            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr["id"] != null && dr["TypeName"] != null)
                    {
                        strRawHtml = strRawHtml + SetRawMaterials(dr["id"].ToString(), dr["TypeName"].ToString());
                    }
                }
            }
            return strRawHtml;
        }
        public string SetRawMaterials(string strId, string strType)
        {

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<tr id=\"upadd_" + strId + "\">");
            sb.Append("<td class='xh_td'>" + strId + "</td>");
            sb.Append("<td>" + strType + "</td>");
            sb.Append("<td align='center'>");
            sb.Append("<a href='#'  onclick='select_max_type(" + strId + ")'><img src='../../../Images/file.gif'/></a>");
            sb.Append("</td>");

            sb.Append("<td align='center'>");
            sb.Append("<a href='#' onclick='Clear_Raw_Type(" + strId + ")'><img src='../../../Images/trash.gif'/></a>");
            sb.Append("</td>");
            sb.Append("</tr>");
            return sb.ToString();
        }
        public string GetRawType(string strMaxtype)
        {
            string strRawHtml = string.Empty;
            Catering_Rules.RawMaterialsInfo crrm = new Catering_Rules.RawMaterialsInfo();
            DataSet ds = crrm.GetList("RMID=" + strMaxtype);
            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr["id"] != null && dr["Name"] != null)
                    {
                        strRawHtml = strRawHtml + SetRawMaterialsa(dr["id"].ToString(), dr["Name"].ToString(),dr["Back"].ToString());
                    }
                }
            }
            return strRawHtml;
        }
        public string SetRawMaterialsa(string strId, string strType,string conter="&nbsp;")
        {

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<tr id=\"upadd_" + strId + "\">");
            sb.Append("<td class='xh_td'>" + strId + "</td>");
            sb.Append("<td>" + strType + "</td>");
            sb.Append("<td>" + conter + "</td>");
            sb.Append("<td align='center'>");
            sb.Append("<a href='javascript:void(0);' onclick='DelRawMaterialsInfoByID(" + strId + ")'><img src='../../../Images/trash.gif'/></a>");
            sb.Append("</td>");
            sb.Append("</tr>");
            return sb.ToString();
        }
        #endregion
        #region 类别设置-菜品设置
        public string GetDishType()
        {
            string strDishHtml = string.Empty;
            Catering_Rules.DishType crdt = new Catering_Rules.DishType();
            DataSet ds = crdt.GetAllList();
            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if (dr["id"] != null && dr["DT"] != null)
                    {
                        strDishHtml = strDishHtml + SetDishMaterials(dr["id"].ToString(), dr["DT"].ToString());
                    }
                }
            }
            return strDishHtml;
        }
        public string SetDishMaterials(string strId, string strType)
        {

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<tr id=\"upadd_" + strId + "\">");
            sb.Append("<td class='xh_td'>" + strId + "</td>");
            sb.Append("<td>" + strType + "</td>");
            sb.Append("<td align='center'>");
            sb.Append("<a href='#'    onclick='Clear_Dish_Type(" + strId + ")'><img src='../../../Images/trash.gif'/></a>");
            sb.Append("</td>");
            sb.Append("</tr>");
            return sb.ToString();
        }
        #endregion
        #endregion

        #region 上传图片
        public string UpImage(FileUpload Fu_Raw_Poto)
        {
            string strMessage = string.Empty;
            string str = View_Operaction_UpFile.uploadPoto(Fu_Raw_Poto, out strMessage);
            string strFilePath = "~/" + View_Operaction_UpFile.UpPotoFolder + "/" + str;
            return strFilePath;
        }
        #endregion

        #region 营养推荐量计算
        public void GetNutrional(ArrayList list, string strold, string strSex, string strLao, string strNumber)
        {
            Catering_Rules.NutritionalStandards crns = new Catering_Rules.NutritionalStandards();

            DataSet ds = crns.GetList("old=" + strold + " and sex=" + strSex + "and laodong=" + strLao);

            Int32 intNumber = Convert.ToInt32(strNumber);
            if (ds != null && ds.Tables.Count > 0)
            {
                DataTable dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr != null && dr[0].ToString().Length > 0)
                        {
                            if (list.Count < 5)
                            {
                                for (int i = 4; i < 18; i++)
                                {
                                    list.Add(Convert.ToInt32(dr[i + 1]) * intNumber);
                                }
                            }
                            else
                            {
                                for (int j = 4; j < 18; j++)
                                {
                                    Int32 inttemp = 0;
                                    int ints = Convert.ToInt32(list[j]);
                                    if (ints > 0)
                                    {
                                        inttemp = inttemp + Convert.ToInt32(Convert.ToInt32(dr[j + 1]) * intNumber);
                                        list[j] = inttemp;
                                    }
                                    else
                                    {
                                        list[j] = Convert.ToInt32(Convert.ToInt32(dr[j + 1]) * intNumber);

                                    }

                                }
                            }

                        }
                    }
                }
            }


        }

        #endregion

        #region 食谱显示
        public void GetDataList(DateTime strs, ArrayList list, Int32 weeklength, string mid)
        {
            Catering.View_Operaction_Common voc = new View_Operaction_Common();

            if (strs != null)
            {

                DateTime dtt = strs;



                string str = "MID=" + mid;

                DataTable dt = voc.GetshipuInfo(dtt.ToShortDateString(), str, weeklength);
                list.Add(voc.Getshipu(dtt.ToShortDateString(), weeklength, dt));
                list.Add(voc.Getshipu(dtt.ToShortDateString(), dt, weeklength));
                list.Add(voc.Getshipu(dtt.AddDays(1).ToShortDateString(), dt, weeklength));
                list.Add(voc.Getshipu(dtt.AddDays(2).ToShortDateString(), dt, weeklength));
                list.Add(voc.Getshipu(dtt.AddDays(3).ToShortDateString(), dt, weeklength));
                list.Add(voc.Getshipu(dtt.AddDays(4).ToShortDateString(), dt, weeklength));
                list.Add(voc.Getshipu(dtt.AddDays(5).ToShortDateString(), dt, weeklength));
                list.Add(voc.Getshipu(dtt.AddDays(6).ToShortDateString(), dt, weeklength));


            }

        }
        #endregion

        #region 采购计划查找食谱
        public string CaitouEdit_Select(string GroupID, string ClassID, string StatTime, string StopTime)
        {
            List<Catering_Model.E_Recipes> list = Caitou_shipu_list(GroupID, ClassID, StatTime, StopTime);
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            foreach (Catering_Model.E_Recipes cmr in list)
            {


                sb.Append(" <tr onclick=\"select_shipu_List(" + cmr.id + ")\"><td class=\"xh_td\">" + cmr.id + "</td>");
                sb.Append(" <td>" + cmr.StateDate.ToShortDateString() + "至" + cmr.StopDate.ToShortDateString() + "食谱</td>");
                sb.Append(" <td> 5 </td>");
                sb.Append("<td>" + cmr.Back + " </td>");

                sb.Append("<Td>" + cmr.temp1 + "</Td>");
                sb.Append(" <td> 3.11 </td>");
                sb.Append("<Td>" + cmr.temp2 + "</Td>");
                sb.Append("</tr>");
                sb.Append("");
            }



            return sb.ToString();
        }
        public string CaitouTemp_Select(string GroupID, string ClassID, string StatTime, string StopTime, string strNumber)
        {
            List<Catering_Model.E_Recipes> list = Caitou_shipu_list(GroupID, ClassID, StatTime, StopTime);
            Catering_Rules.Purchase crp = new Catering_Rules.Purchase();
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            DataSet ds = crp.GetList(" EditDate  between '" + StatTime + "' and' " + StopTime + "'");
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        if (dr != null && dr[0] != null && dr[0].ToString().Length > 0)
                        {

                            sb.Append(" <tr onclick=\"select_jighua_List(" + dr["id"] + ")\"><td class=\"xh_td\">" + dr["id"] + "</td>");
                            sb.Append(" <td>" + dr["PPName"] + "</td>");
                            sb.Append(" <td>" + dr["BRid"] + " </td>");
                            sb.Append("<td>" + dr["URid"] + " </td>");

                            sb.Append("<Td>" + 5 + "</Td>");
                            sb.Append(" <td>" + strNumber + "</td>");
                            sb.Append("<Td>" + dr["Back"] + "</Td>");
                            sb.Append("</tr>");
                            sb.Append("");
                        }
                    }
                }
            }

            return sb.ToString();
        }
        /// <summary>
        /// 获取时间段的食谱信息
        /// </summary>
        /// <param name="GroupID"></param>
        /// <param name="ClassID"></param>
        /// <param name="StatTime"></param>
        /// <param name="StopTime"></param>
        /// <returns></returns>
        public List<Catering_Model.E_Recipes> Caitou_shipu_list(string GroupID, string ClassID, string StatTime, string StopTime)
        {
            List<Catering_Model.E_Recipes> list = new List<Catering_Model.E_Recipes>();

            string str = "CLassID=" + ClassID + " and GroupID= " + GroupID + " and  date between '" + StatTime + "' and '" + StopTime + "'";
            DataSet ds = new Catering_Rules.ViewOperaction().GetViewToDataSet("recipe_information_Group", str);
            if (ds != null && ds.Tables.Count > 0)
            {
                DataTable dt = ds.Tables[0];
                var ord = from ords in dt.AsEnumerable()
                          orderby ords.Field<Int32>("MID")
                          select ords.Field<Int32>("MID");

                Catering_Rules.T_Recipes crr = new Catering_Rules.T_Recipes();
                foreach (Int32 id in ord.Distinct())
                {

                    Catering_Model.E_Recipes cmr = crr.GetModel(id);
                    list.Add(cmr);

                }


            }
            return list;
        }
        /// <summary>
        /// 获取采购计划
        /// </summary>
        /// <param name="GroupID"></param>
        /// <param name="ClassID"></param>
        /// <param name="StatTime"></param>
        /// <param name="StopTime"></param>
        /// <returns></returns>
        public DataTable Caitou_jihua_list(string GroupID, string ClassID, string StatTime, string StopTime)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            string str = "riclassid=" + ClassID + " and rigropid= " + GroupID + " and  pimdate between '" + StatTime + "' and '" + StopTime + "'";
            DataSet ds = new Catering_Rules.ViewOperaction().GetcaigoujihuaToDataSet(str);
            DataTable dt = new DataTable();
            if (ds != null && ds.Tables.Count > 0)
            {
                dt = ds.Tables[0];


            }

            return dt;
        }


        #endregion

        #region 食物名称
        public string GetDishName(object strDishID)
        {
            string strName = string.Empty;
            if (strDishID == null)
            {
                strName = "&nbsp;";
            }
            else
            {
                Catering_Rules.T_Dish crd = new Catering_Rules.T_Dish();
                if (strDishID.ToString().Length > 0)
                {
                    Catering_Model.E_Dish cmd = crd.GetModel(Convert.ToInt32(strDishID));
                    strName = cmd.Name;
                }
            }
            return strName;
        }
        #endregion

        #region  菜谱库设置
        public string ShowLibery(string strAearID, string strClassID)
        {
            Catering_Rules.library crl = new Catering_Rules.library();
            DataSet ds = crl.GetAllList();

            Catering_Rules.Group_tedian crgt = new Catering_Rules.Group_tedian();
            DataSet ds_tedian = crgt.GetAllList();
            string stroption = string.Empty;
            if (ds_tedian != null && ds_tedian.Tables.Count > 0)
            {
                stroption = stroption + "<select style=\"width:100px\" disabled=\"disabled\">";
                foreach (DataRow dr in ds_tedian.Tables[0].Rows)
                {
                    stroption = stroption + " <option value=\"" + dr["id"] + "\">" + dr["PName"] + "</option>";
                }
                stroption = stroption + "</select> ";
            }
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow drliber in ds.Tables[0].Rows)
                {
                    sb.Append(" <tr id=\"tr_" + drliber["id"] + "\">");
                    sb.Append(" <td class=\"xh_td\"> " + drliber["id"] + "  </td>");
                    sb.Append(" <td>" + drliber["LName"] + "</td>");
                    sb.Append("  <td> ");
                    sb.Append(stroption);
                    sb.Append(" </td>");
                    sb.Append("<td>" + (drliber["Back"].ToString() == "" ? "&nbsp;" : drliber["Back"].ToString()) + "</td>");
                    sb.Append(" <td align=\"center\">  <a href=\"javascript:void(0);\">  <img src=\"../../../Images/trash.gif\"  onclick=\"Del_set_Libery(" + drliber["id"] + ")\"/></a> </td>");
                    sb.Append("</tr>");
                }
            }
            return sb.ToString();
        }


        public Boolean AddLibery(string strLibery)
        {
            Boolean bl = false;
            string[] Groups = strLibery.Split(new char[] { '|' });
            foreach (string strs in Groups)
            {
                if (strs.Length > 0)
                {
                    Catering_Model.library cml = new Catering_Model.library();
                    Catering_Rules.library crl = new Catering_Rules.library();
                    string[] rows = strs.Split(new char[] { ',' });
                    cml.id = crl.GetMaxId();
                    cml.LName = rows[0];
                    cml.Back = rows[2];
                    cml.temp1 = rows[1];
                    crl.Add(cml);
                    bl = true;
                }

            }

            return bl;


        }
        #endregion

        #region 导入食谱
        public string GetShipuList(string strAeraID, string strClass, Int32 RadionID)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            Catering_Rules.T_Recipes crgc = new Catering_Rules.T_Recipes();
            //"AreaID=" + strAeraID + "  and ClassIDs=" + strClass
            ;
            List<Catering_Model.E_Recipes> list = crgc.GetModelList("");
            foreach (Catering_Model.E_Recipes cmr in list)
            {
                int Number = 0;
                sb.Append("<tr onclick=\"shipu_list_Select(" + cmr.id + ")\" id=\"shipu_list_" + cmr.id + "\">");
                sb.Append(" <td class=\"xh_td\">" + cmr.id + "</td>");
                sb.Append(" <td> " + cmr.CateringName + "</td>");
                sb.Append("<td>" + Getzhouqi(cmr.StateDate, cmr.StopDate, RadionID) + " </td>");
                sb.Append("<td>" + Convert.ToDateTime(cmr.Back) + " </td>");
                sb.Append("<td>" + cmr.temp2 + "</td>");
                sb.Append("<td>" + AVGold(cmr, out Number) + "</td>");
                sb.Append("<td>" + Number + "</td>");
                sb.Append("</tr>");
            }
            return sb.ToString();
        }
        public int AVGold(Catering_Model.E_Recipes cmr, out int Number)
        {
            Catering_Model.GroupCatering cmgc = new Catering_Rules.GroupCatering().GetModel(cmr.GroupID);
            int i = (cmgc.MOld + cmgc.Wold) / 2;
            Number = cmgc.WNumber + cmgc.MNumber;
            return i;
        }
        public int Getzhouqi(DateTime strStrat, DateTime strStop, Int32 RadionID)
        {
            TimeSpan ts = Convert.ToDateTime(strStop) - Convert.ToDateTime(strStrat);
            int intweek = 0;

            if (ts.Days % RadionID == 0)
            {
                intweek = ts.Days / RadionID;
            }
            else
            {
                intweek = ts.Days / RadionID + 1;
            }
            return intweek;
        }
        #endregion
    }
}